<template>
  <div class="commItem">
    <div class="top">
      <div class="uimg">
        <img :src="item.u.p" alt="" />
      </div>
      <div class="uname">
        <h5>{{ item.u.n }}</h5>
        <i>LV.{{ item.u.lvl }}</i>
      </div>
      <p class="like">
        <i></i>
        <span>{{ item.like_count }}</span>
      </p>
    </div>
    <div class="content">
      <ul>
        <li v-for="(item1, index) in contents" :key="index">
          {{ item1.c }}
        </li>
      </ul>
      <div class="child-comments" v-if="children.length != 0">
        <ul>
          <li v-for="child in children" :key="child.id">
            <b>{{ child.reply_user.n }}:</b>
            <span>{{ child.content[0].c }}</span>
          </li>
        </ul>
        <p>共 {{ item.child_comments.length }} 条回复</p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ["item"],
  computed: {
    contents() {
      return this.item.content;
    },
    children() {
      return this.item.child_comments;
    },
  },
};
</script>

<style lang="less" scoped>
.commItem {
  padding: 10px 15px;
  margin-top: 10px;
  .top {
    display: flex;
    .uimg {
      width: 25px;
      height: 25px;
      background-color: #f5f5f5;
      border-radius: 50%;
      img {
        width: 100%;
        border-radius: 50%;
        vertical-align: middle;
      }
    }
    .uname {
      display: flex;
      flex: 1;
      align-items: center;
      h5 {
        font-size: 15px;
        margin-left: 10px;
      }
      i {
        color: goldenrod;
        font-size: 12px;
        margin-left: 5px;
      }
    }
    .like {
      display: flex;
      align-items: center;
      i {
        display: block;
        width: 15px;
        height: 15px;
        background-image: url("../assets/cml.png");
        background-size: 100%;
        background-position: center;
        margin-right: 3px;
      }
    }
  }
  .content {
    margin-left: 35px;
    font-size: 14px;
    margin-top: 10px;
    .child-comments {
      background-color: #fafafa;
      border-radius: 5px;
      padding: 10px;
      font-size: 12px;
      margin-top: 10px;
      p {
        color: #666;
        padding-top: 5px;
      }
      ul {
        li {
          margin-bottom: 5px;
        }
      }
    }
  }
}
</style>